package com.dukla.picbak;

import io.minio.MinioClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class AppConfig {

    private static final Logger logger = LoggerFactory.getLogger(AppConfig.class);

    @Value("${minio.endpoint}")
    String minioEndpoint;

    @Value("${minio.root.user}")
    String minioUser;

    @Value("${minio.root.password}")
    String minioPassword;

    @Bean
    public MinioClient minioClient() {
        logger.info("Create Minio client,minioEndpoint={},minioUser={}",minioEndpoint,minioUser);
        return MinioClient.builder()
                .endpoint(minioEndpoint)
                .credentials(minioUser, minioPassword)
                .build();
    }
}
